package com.lbb.springboot.util;

import com.lbb.springboot.entity.vo.VehicleVo;

import java.util.HashMap;
import java.util.Map;

import static com.lbb.springboot.util.HttpClientUtils.post;

/**
 * @author likanghong
 */
public class Test2 {
    public static void main(String[] args) {
        VehicleVo vehicleVo = new VehicleVo();
        vehicleVo.setChepaihao("粤A90231");
        vehicleVo.setCxqghypt(true);
        String url = "http://ticket.gdcd.gov.cn:8010/IndustryData/Vehicle";
        Map<String, String> dataMap = new HashMap<>();
        dataMap.put("chepaiyanse", vehicleVo.getChepaiyanse());
        dataMap.put("chepaihao", vehicleVo.getChepaihao());
        dataMap.put("cxqghypt", vehicleVo.isCxqghypt() + "");
        String post = post(url, dataMap, "UTF-8");
//        System.out.println("post>>>>>>>>>>>{}"+post);

        int indexof = post.indexOf("ViewVehicleDetail");
        String substring = post.substring(indexof, indexof + 174);
        String[] split = substring.split("'");

        String id = split[1];
        vehicleVo.setChepaihao(split[3]);
        vehicleVo.setChepaiyanse(split[5]);
        url = "http://ticket.gdcd.gov.cn:8010/IndustryData/VehicleDetail?" +
                "id=" + id
                + "&chepaihao=" + vehicleVo.getChepaihao()
                + "&chepaiyanse=" + vehicleVo.getChepaiyanse()
                + "&cxqghypt=" + vehicleVo.isCxqghypt();

//        logger.info("url>>>>>>>>>>>{}", url);

        String deatils = HttpClientUtils.get(url);
        System.out.println(deatils);
    }
}
